<?php
include "templates/page_start.tpl";

/**
 * Daten:
 * categories	Array mit Arrays für jedes Porzellan Objekt. Jedes
 * 		Array hat folgende Werte:
 * 		cat_id		ID des Objektes
 * 		cat_name	Name des Objektes
 */
?>

<table id='cat_list'>
    <?php

    $item_last = count($data["categories"]);
    $item_count = 0;
    foreach ($data["categories"] as $cat_id => $categorie) {
        $item_count++;
        ?>
        <td class="overview_item" id="cat_item_<?php echo $cat_id; ?>" />


        <a href='?section=china&action=overview&cat_id=<?php echo $cat_id; ?>'>
            <table>
                <tr><td><img src="<?php echo $categorie['image_url']; ?>"></img></td></tr>
                <tr><td class="cat_item_name overview_lable"><?php echo $categorie['cat_name'] ?></td></tr>
            </table>
        </a>
    </td>
    <?php
    # Zeilen abschluss nach 5. Element
    if ($item_count % ITEMS_OVERVIEW == 0) {
        echo '</tr>';
        echo '<tr>';
    }
    #Abschluss der letzten Zeile
    if ($item_count == $item_last) {
        echo '</tr>';
    }
}
?>
</table>

<?php 
if ((count($data["categories"]) >= 1 ) && (count($data["objects"]) >= 1 )) {
    echo "</div><div class=\"line\"> &nbsp; </div><div id = \"content\">";
}
?>

<table id='obj_list'>
    <?php
    
    $item_last = count($data["objects"]);
    $item_count = 0;
    foreach ($data["objects"] as $obj_id => $object) {
        $item_count++;
        ?>
        <td class="overview_item" id="obj_item_<?php echo $obj_id; ?>" />


        <a href="?section=china&action=view&obj_id=<?php echo $object["obj_id"]; ?>">
            <table>
                <tr><td class="obj_item_img"><img src="<?php echo $object["obj_img_url"]; ?>"></img></td></tr>
                <tr><td class="obj_item_name overview_lable"><?php echo $object["obj_name"] ?></td></tr>
            </table>
        </a>
    </td>
    <?php
    # Zeilen abschluss nach 5. Element
    if ($item_count % ITEMS_OVERVIEW == 0) {
        echo '</tr>';
        echo '<tr>';
    }
    #Abschluss der letzten Zeile
    if ($item_count == $item_last) {
        echo '</tr>';
    }
    
}
?>
</table>




<?php
/*
  <a href='?section=china&action=view&cat_id=<?php echo $cat_id; ?>'>
  <img src='<?php echo $categorie['image_url']; ?>'></img>
  </a>
  <br />
  <table>
  <tr>
  <td><b>Name:</b></td>
  <td><?php echo $categorie['cat_name'] ?></td>
  </tr>

  </table>
 * <?php	

  foreach ($data["categories"] as $cat_id => $categorie) {

  if (($cat_id  == 0) || ($cat_id   % 6 == 0)) echo "<tr>\n";
  ?>
  <td id='cat_item' class='cat_item<?php echo $cat_id ?>'>

  <?php echo $cat_id ?>

  </td>
  <?php
  if (($cat_id % 5) == 0) {
  echo "<tr/>\n";
  }
  }
  ?>
 */
?>
<?php
include "templates/page_end.tpl";
?>